<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>九铭资产管理-找回密码</title>
		<link rel="stylesheet" href="/Public/Home/css/jiuming.css" />
		<link rel="shortcut icon" href="http://jlzpublicbucket.oss-cn-hangzhou.aliyuncs.com/assets/jiujming.ico" type="image/x-icon">
	</head>
	<body>
		
		<div class="register-top">
			<div class="register-top-content">
				 <div class="register-top-logo"></div>
				 <div class="register-top-text">重置登录密码</div>
			</div>
		</div>
		
		<div class="password-back">
			<div class="title">密码找回</div>
			
			<div class="step" id="step1">
				<div class="input-box">
					<div class="item">请输入您的账号：</div>
					<div class="inpput-text">
						<input type="text" value="" id="tel" placeholder="请输入手机号码"/>
					</div>
				</div>
				<div class="input-box">
					<div class="item">验证码：</div>
					<div class="inpput-text">
						<input type="text" value="" id="code1" placeholder="请输入短信验证码"/>
						<button class="btn" id="getCode1">验证码</button>
					</div>
				</div>
				<div class="input-box margin-top-50">
					<div class="item"></div>
					<div class="inpput-text">
						<button class="btn btn-style" id="next1">下一步</button>
					</div>
				</div>
			</div>
			
			<div class="step hidden" id="step2">
				<div class="input-box">
					<div class="item">新密码：</div>
					<div class="inpput-text">
						<input type="password" value="" id="password1" placeholder="请输入新密码"/>
					</div>
				</div>
				<div class="input-box">
					<div class="item">重复新密码：</div>
					<div class="inpput-text">
						<input type="password" value="" id="password2" placeholder="请再次输入新密码"/>
					</div>
				</div>
				<div class="input-box margin-top-50">
					<div class="item"></div>
					<div class="inpput-text">
						<input type="hidden" value="" id="confirm_tel" />
						<button class="btn btn-style" id="sub">提交</button>
					</div>
				</div>
			</div>
			
			<div class="step hidden" id="step3">
				
				<div class="success-pwd-back">
					<img src="http://jlzpublicbucket.oss-cn-hangzhou.aliyuncs.com/assets/pwd_success.png" />
					<p>密码修改成功！</p>
				</div>
				
				<div class="input-box margin-top-50">
					<div class="item"></div>
					<div class="inpput-text">
						<a class="btn toLogin" href="{:U('Index/login',array('token' => 'dvaglg1469847559'))}">立即登录</a>
					</div>
				</div>
			</div>
			
		</div>
		
		<div class="register-footer">
			<p><a href="http://www.jiumingfund.com">http://www.jiumingfund.com</a></p>
		</div>
		
		<script type="text/javascript" src="/Public/Home/js/jquery.1.9.1.min.js"></script>
		<script>
			function getCode(obj,tel){
				$.ajax({
					url:"{:U('Index/password_back',array('token' => 'dvaglg1469847559'))}",
    				type:"POST",
    				dataType:"json",
    				data:{
    					tel:tel,
    					step:1
    				},
    				success:function(data){
    					if(data.status ==1){
    						var i = 60;
    						obj.addClass("disabled");
    						var timer = setInterval(function(){
    							obj.text(i+"s后重试");
    							i--;
    							if(i == -1){
    								clearInterval(timer);
    								obj.removeClass("disabled");
    								obj.text("获取验证码");
    							}
    						},1000)
    					}else{
    						alert(data.msg);
    					}
    				}
  			})
			}
			
			$("#getCode1").bind('click',function(){
				var father = $(this);
				var tel = $("#tel").val();
				if(tel == ''){
					alert("请输入手机号码");
  				$("#tel").focus();
  				return false;
				}
				if(father.hasClass('disabled')){
					return false;
				}else{
					getCode(father,tel);
				}
			})
			
			$("#next1").click(function(){
				var tel = $("#tel").val();
				var code = $("#code1").val();
				
				if(tel == ''){
					alert("请输入手机号码");
  				$("#tel").focus();
  				return false;
				}
				if(code == ''){
					alert("请输入验证码");
  				$("#code1").focus();
  				return false;
				}
				$.ajax({
					url:"{:U('Index/password_back',array('token' => 'dvaglg1469847559'))}",
					type:"POST",
					dataType:"json",
					data:{
						tel:tel,
						code:code,
						step:2
					},
					success:function(data){
						if(data.status == 1){
							$("#confirm_tel").val(tel);
							$("#step1").addClass('hidden');
							$("#step2").removeClass('hidden');
						}else{
							alert(data.msg);
						}
					}
				})
			})
			
			$("#sub").click(function(){
				var pwd1 = $("#password1").val();
				var pwd2 = $("#password2").val();
				var tel = $("#confirm_tel").val();
				
				if(pwd1 == ''){
					alert("请输入新的密码");
					$("#password1").focus();
					return false;
				}
				if(pwd2 == ''){
					alert("请再次输入新的密码");
					$("#password2").focus();
					return false;
				}
				if(pwd1 != pwd2){
					alert("两次密码输入不一致，请重新输入");
					$("#password2").focus();
					return false;
				}
				$.ajax({
					url:"{:U('Index/password_back',array('token' => 'dvaglg1469847559'))}",
					type:"POST",
					dataType:"json",
					data:{
						tel:tel,
						password:pwd2,
						step:3
					},
					success:function(data){
						if(data.status == 1){
							$("#step2").addClass('hidden');
							$("#step3").removeClass('hidden');
						}else{
							alert(data.msg);
						}
					}
				})
			})
		</script>
	</body>
</html>
